export const storage = {
  set(key, payload) {
    localStorage.setItem(key, payload);
  },
  get(key) {
    return localStorage.getItem(key);
  },
};

export const getScreenInfo = () => {
  return {
    screenWidth: screen.width,
    screenHeight: screen.height,
    bodyWidth: document.body.offsetWidth,
    bodyHeight: document.body.offsetHeight,
    availWidth: screen.availWidth,
    availHeight: screen.availHeight,
  };
};

export const debound = (callback, ms) => {
  let timerId = null;
  return function (...args) {
    if (timerId) {
      clearTimeout(timerId);
    }
    timerId = setTimeout(() => {
      callback.call(this, args);
      timerId = null;
    }, ms);
  };
};
